import {ref , onMounted} from "vue"
import axios from "axios"
export default function useLoadImg(){
  //请求图片的数据
  const isLoading = ref(true)
  const imgUrl = ref("")
  //请求
  onMounted(()=>{
    axios
      .get("https://api.thecatapi.com/v1/images/search")
      .then((res) => {
        imgUrl.value = res.data[0].url;
        isLoading.value = false;
      })
      .catch((e) => {
        console.log(e.message);
      });
  })

  return{
    isLoading,
    imgUrl
  }
}